package com.whfc.mach.enums;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/7/22 11:47
 */
public enum WorkState {
    OFFLINE(0, "离线"),

    STOP(1, "停止"),

    IDLE(2, "怠速"),

    RUN(3, "工作"),

    SLEEP(4, "休眠"),

    POWER_OFF(5, "断电"),

    ERROR(6, "错误");

    private Integer value;

    private String desc;

    WorkState(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static WorkState parseByValue(Integer value) {
        WorkState[] states = WorkState.values();
        for (WorkState state : states) {
            if (state.getValue().equals(value)) {
                return state;
            }
        }
        return ERROR;
    }
}
